package com.company.woye.checkscan;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;

import com.company.woye.MyApplication;
import com.company.woye.R;
import com.company.woye.base.BaseActivity;
import com.company.woye.checkmakesure.MakeSureCheckActivity;
import com.company.woye.checkscan.adapte.CheckScanListviewAdapter;
import com.company.woye.checkscan.bean.AllPiece;
import com.company.woye.checkscan.bean.StartScan;
import com.company.woye.internet.KjjPHCallBack;
import com.company.woye.quantitycheck.QuantityCheck2Activity;
import com.company.woye.readycommit.ReadyCommitActivity;
import com.company.woye.taiorcheckSize.TaiorCheckDetailActivity;
import com.company.woye.taiorcheckSize.TaiorCheckSizeActivity;
import com.company.woye.taiorcheckSize.bean.TaiorSizeBean;
import com.company.woye.taiorcheckquestion.TaiorCheckQuestionActivity;
import com.company.woye.utils.Constans;
import com.company.woye.utils.DBUtil;
import com.company.woye.utils.DataUtils;
import com.company.woye.utils.ScannerManager;
import com.company.woye.utils.Toaster;
import com.zhy.http.okhttp.OkHttpUtils;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.Call;
import okhttp3.MediaType;

import static com.company.woye.MyApplication.UrlCut;

public class CheckScanActivity extends BaseActivity {

    @BindView(R.id.iv_on_package_back)
    ImageView ivOnPackageBack;
    @BindView(R.id.tv_on_package_back)
    TextView tvOnPackageBack;
    @BindView(R.id.tv_sure)
    TextView tvSure;
    @BindView(R.id.tv_checkout_box_operation)
    TextView tvCheckoutBoxOperation;
    @BindView(R.id.tv_checkout_question_number)
    TextView tvCheckoutQuestionNumber;
    @BindView(R.id.tv_checkout_exception)
    TextView tvCheckoutException;
    @BindView(R.id.tv_check_sure)
    TextView tvCheckSure;
    @BindView(R.id.tv_ready_commit)
    TextView tvReadyCommit;
    @BindView(R.id.tv_refresh)
    TextView tvRefresh;
    @BindView(R.id.sp_dept)
    Spinner spDept;
    @BindView(R.id.sp_factory)
    Spinner spFactory;
    @BindView(R.id.ed_make_person)
    TextView edMakePerson;
    @BindView(R.id.tv_LSX)
    Spinner sp_LSX;
    @BindView(R.id.tv_date)
    TextView tvDate;
    @BindView(R.id.tv_all_part)
    TextView tvAllPart;
    @BindView(R.id.edit_Barcode)
    EditText editBarcode;
    @BindView(R.id.bt_sure_barcode)
    Button btSureBarcode;
    @BindView(R.id.tv)
    TextView tv;
    @BindView(R.id.lv_detail)
    ListView lvDetail;
    @BindView(R.id.ll_on_package_summary)
    LinearLayout llOnPackageSummary;
    @BindView(R.id.rl)
    RelativeLayout rl;
    private String  cDate = "", LoginUserNo = "", inputId = "", yghXm = "", ygh = "", inputMan="" , bidDept = "";
    String FormType = getClass().getSimpleName();
    private List<String> deptNameList=new ArrayList<>(), cJnameList=new ArrayList<>(), LsxNameList=new ArrayList<>();
    private ArrayAdapter<String> deptAdapter, cjNameAdapter, lsxNameAdapter;
    private final int MSG_FIND_DEPT = 9001;
    private final int MSG_FIND_CJNAME = 9002;
    private final int MSG_FIND_DATE = 9003;
    private final int MSG_ERROR = 9007;
    private final int MSG_FIND_LSXNAME = 9008;
    private final int MSG_FIND_ZDR = 9009;
    private JSONArray deptJsonarray, cJnameJsonarray, cDateJsonarray, LsxNameJsonArray, ZDRJsonArray;
    private ScannerManager scannerManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (scannerManager.dispatchKeyEvent(event)) {
            return true;
        }
        return super.dispatchKeyEvent(event);
    }

    @Override
    public int setLayoutId() {
        return R.layout.activity_check_scan;
    }

    @Override
    public void initView() {

        LoginUserNo = MyApplication.curLoginUserNo;
        tvDate.setText(DataUtils.getNowData() + " 00:00:00");
        getDepaName();
        editBarcode.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                editBarcode.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
                InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
                imm.showSoftInput(editBarcode, InputMethodManager.SHOW_FORCED);
            }
        });
        editBarcode.setOnKeyListener(new View.OnKeyListener() {
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (event != null) {
                    if ((event.getAction() == KeyEvent.ACTION_UP) && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                        return true;
                    }
                }
                return false;
            }
        });
        editBarcode.requestFocus();
        editBarcode.requestFocusFromTouch();
        //拦截扫描事件
        scannerManager = new ScannerManager(new ScannerManager.OnScanListener() {
            @Override
            public void onResult(String code, String deviceName) {
                String nowCode = dealCode(code).trim();
                    if (nowCode.length() > 12 || nowCode.length() == 12) {
                        nowCode = nowCode.substring(nowCode.length() - 12);
                        editBarcode.setText(nowCode);
                        scanCode();
                    }
            }
        }, editBarcode.getContext());

    }

    //保留英文和数字
    private String dealCode(String code) {
        return code.replaceAll("[^a-zA-Z0-9$%]", "");
    }

    private void scanCode() {
        /**
         * {
         *   "bbm": "制衣二部",
         *   "bmName": "制衣二部(1)",
         *   "cjName": "裁剪一工场",
         *   "inputId": "C2101105A",
         *   "inputMan": "裁一检验5",
         *   "kdrq": "2021-12-02 00:00:00",
         *   "lsx": "1-5",
         *   "token": "7e0daaaed1a1543727122788a4e5398e7c23e88b075a32e3922a6d96b5642db9",
         *   "txm": "267000980263",
         *   "ygh": "何树珍",
         *   "yghXm": "21027477"
         * }
         */
        String bmName = "";
        String cjName = "";
        String lsxName = "";
        if (deptNameList != null && deptNameList.size() > 0) {
            bmName = spDept.getSelectedItem().toString();
        }
        if (cJnameList != null && cJnameList.size() > 0) {
            cjName = spFactory.getSelectedItem().toString();
        }
        if (LsxNameList != null && LsxNameList.size() > 0) {
            lsxName = sp_LSX.getSelectedItem().toString();
        }
        String kdrq = cDate;
        JSONObject params = new JSONObject();
        try {
            params.put("cjName", cjName);
            params.put("bbm", bidDept);
            params.put("bmName", bmName);
            params.put("inputId", inputId);
            params.put("inputMan", inputMan);
            params.put("kdrq", cDate);
            params.put("lsx", lsxName);
            params.put("txm", editBarcode.getText().toString());
            params.put("ygh", ygh);
            params.put("yghXm", yghXm);
            params.put("token", Constans.token);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.e("提交数据", params.toString());
        Log.e("访问地址", Constans.IP + "szapi/third/BdMlcj/bdJysm");
        OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json"))
                .content(params.toString()).url(Constans.IP + "szapi/third/BdMlcj/bdJysm").build().execute(new KjjPHCallBack<StartScan>(StartScan.class, CheckScanActivity.this, true) {
            @Override
            public void myError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(StartScan response, int id) {
                Toaster.showLong(CheckScanActivity.this, response.getMsg());
                if (response.getMsg().equals("102")) {
                    getList();
                }
            }
        });
    }

    private void getList() {
        /**
         {
         "bbm": "制衣二部",
         "bmName": "制衣二部(1)",
         "cjName": "裁剪一工场",
         "inputId": "C2101105A",
         "inputMan": "裁一检验5",
         "kdrq": "2021-12-02 00:00:00",
         "lsx": "1-5",
         "token": "7e0daaaed1a1543727122788a4e5398e7c23e88b075a32e3922a6d96b5642db9"
         }
         */
        String bmName = "";
        String cjName = "";
        String lsxName = "";
        if (deptNameList != null && deptNameList.size() > 0) {
            bmName = spDept.getSelectedItem().toString();
        }
        if (cJnameList != null && cJnameList.size() > 0) {
            cjName = spFactory.getSelectedItem().toString();
        }
        if (LsxNameList != null && LsxNameList.size() > 0) {
            lsxName = sp_LSX.getSelectedItem().toString();
        }
        String kdrq = cDate;
        JSONObject params = new JSONObject();
        try {
            params.put("bbm", bidDept);
            params.put("bmName", bmName);
            params.put("cjName", cjName);
            params.put("inputId", inputId);
            params.put("inputMan", inputMan);
            params.put("kdrq", kdrq);
            params.put("lsx", lsxName);
            params.put("token", Constans.token);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.e("提交数据", params.toString());
        Log.e("访问地址", Constans.IP + "szapi/third/BdMlcj/countBdJysm");
        OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json"))
                .content(params.toString()).url(Constans.IP + "szapi/third/BdMlcj/countBdJysm").build().execute(new KjjPHCallBack<AllPiece>(AllPiece.class, CheckScanActivity.this, true) {
            @Override
            public void myError(Call call, Exception e, int id) {

            }

            @Override
            public void onResponse(AllPiece response, int id) {
                Toaster.showLong(CheckScanActivity.this, response.getMsg());
                if (response.getMsg().equals("success")) {
                    if (response.getData() != null && response.getData().size() > 0) {
                        int Alliece = 0;
                        for (int i = 0; i < response.getData().size(); i++) {
                            Alliece += response.getData().get(i).getShl();
                        }
                        tvAllPart.setText(Alliece + "");
                        lvDetail.setAdapter(new CheckScanListviewAdapter(CheckScanActivity.this, response.getData()));
                    }else {
                        lvDetail.setAdapter(null);
                    }
                } else {
                    lvDetail.setAdapter(null);
                }
            }
        });
    }

    private void getDate() {
        String sqlFindcJname = " EXEC GetCheckKdrq @InputDate='" + tvDate.getText().toString() + "'";
        ReadSQLData(sqlFindcJname, "GetCheckKdrq");
    }

    private void getLsxName() {
        String sqlFindLsxName = "EXEC  AGV_Basic_GetLsxName @UserNo ='" + LoginUserNo + "'" + ", @cj_name ='" + (cJnameList.size() > 0 ? spFactory.getSelectedItem() : "") + "', @FormType ='" + FormType + "'" + ", @OperType ='GetLsxName'";
        ReadSQLData(sqlFindLsxName, "LsxName");
    }

    private void getMakePersonInfo() {
        //调用WebService过程并处理界面更新;
        String sqlFindLsxName = "EXEC AGV_Basic_GetCheckID @bmName='" + (deptNameList.size() > 0 ? spDept.getSelectedItem() : "") + "',@cjName='" + (cJnameList.size() > 0 ? spFactory.getSelectedItem() : "") + "',@groupName='" + (LsxNameList.size() > 0 ? sp_LSX.getSelectedItem() : "") + "'";
        ReadSQLData(sqlFindLsxName, "ZDR");
    }

    private void getDepaName() {
        String sqlFindDept = "EXEC  AGV_Basic_GetBbmName @UserNo ='" + LoginUserNo + "'" + ", @FormType ='" + FormType + "'" + ", @OperType ='GetBbmName'";
        ReadSQLData(sqlFindDept, "dept");
    }

    private void getCjName() {
        String sqlFindcJname = "EXEC  AGV_Basic_GetSewCjName @bmName='"+(deptNameList.size() > 0 ? spDept.getSelectedItem() : "")+"', @UserNo ='" + LoginUserNo + "'" + ", @FormType ='" + FormType + "'" + ", @OperType ='GetSewCjName'";
        ReadSQLData(sqlFindcJname, "cJname");

    }

    private void ReadSQLData(String sql, String type) {
        System.out.print("----存储过程:" + sql);
        Runnable run = new Runnable() {
            @Override
            public void run() {
                try {
                    /**
                     * [{"RoleName":"管理员"},{"RoleName":"调度"},{"RoleName":"装框操作"},{"RoleName":"物流运转"},{"RoleName":"试装箱"}]
                     */
                    JSONArray jsonArray = DBUtil.QuerySQL2JSON(UrlCut, sql);
                    System.out.print("----返回结果：" + jsonArray);
                    //部门
                    if (type.equals("dept")) {
                        deptJsonarray = jsonArray;
                        //刷新界面;
                        Message msg = new Message();
                        msg.what = MSG_FIND_DEPT;
                        handler.removeMessages(msg.what);
                        handler.sendMessage(msg);
                        return;
                    }
                    //时间
                    if (type.equals("GetCheckKdrq")) {
                        cDateJsonarray = jsonArray;
                        //刷新界面;
                        Message msg = new Message();
                        msg.what = MSG_FIND_DATE;
                        handler.removeMessages(msg.what);
                        handler.sendMessage(msg);
                        return;
                    }
                    //车间
                    if (type.equals("cJname")) {
                        cJnameJsonarray = jsonArray;
                        //刷新界面;
                        Message msg = new Message();
                        msg.what = MSG_FIND_CJNAME;
                        handler.removeMessages(msg.what);
                        handler.sendMessage(msg);
                        return;
                    }
                    //组别
                    if (type.equals("LsxName")) {
                        LsxNameJsonArray = jsonArray;
                        //刷新界面;
                        Message msg = new Message();
                        msg.what = MSG_FIND_LSXNAME;
                        handler.removeMessages(msg.what);
                        handler.sendMessage(msg);
                        return;
                    }
                    if (type.equals("ZDR")) {
                        ZDRJsonArray = jsonArray;
                        //刷新界面;
                        Message msg = new Message();
                        msg.what = MSG_FIND_ZDR;
                        handler.removeMessages(msg.what);
                        handler.sendMessage(msg);
                        return;
                    }
                } catch (Exception e) {
                    Message msg = new Message();
                    msg.what = MSG_ERROR;
                    handler.removeMessages(msg.what);
                    handler.sendMessage(msg);
                }

            }

        };
        new Thread(run).start();
    }

    Handler handler = new Handler() {
        @Override
        public void handleMessage(@NonNull Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                //获取部门
                case MSG_FIND_DEPT:
                    if (deptJsonarray != null && deptJsonarray.length() > 0) {
                        deptNameList = new ArrayList<>();
                        for (int i = 0; i < deptJsonarray.length(); i++) {
                            try {
                                deptNameList.add(deptJsonarray.optJSONObject(i).get("BbmName").toString());
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                        deptAdapter = new ArrayAdapter<String>(CheckScanActivity.this, android.R.layout.simple_dropdown_item_1line, deptNameList);
                        spDept.setAdapter(deptAdapter);
                        spDept.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                Log.e("选择", spDept.getSelectedItem().toString().substring(0, 4));
                                bidDept = spDept.getSelectedItem().toString().substring(0, 4);
                                //获取车间
                                getCjName();
                            }
                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                    }
                    //获取车间
                    getCjName();
                    break;
                //获取车间
                case MSG_FIND_CJNAME:
                    if (cJnameJsonarray != null && cJnameJsonarray.length() > 0) {
                        cJnameList = new ArrayList<>();
                        for (int i = 0; i < cJnameJsonarray.length(); i++) {
                            try {
                                cJnameList.add(cJnameJsonarray.optJSONObject(i).get("CjName").toString());
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                        cjNameAdapter = new ArrayAdapter<String>(CheckScanActivity.this, android.R.layout.simple_dropdown_item_1line, cJnameList);
                        spFactory.setAdapter(cjNameAdapter);
                        spFactory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                                getLsxName();
                            }

                            @Override
                            public void onNothingSelected(AdapterView<?> adapterView) {

                            }
                        });
                    }
                    getLsxName();
                    break;

                //获取组别
                case MSG_FIND_LSXNAME:
                    if (LsxNameJsonArray != null && LsxNameJsonArray.length() > 0) {
                        LsxNameList = new ArrayList<>();
                        for (int i = 0; i < LsxNameJsonArray.length(); i++) {
                            try {
                                LsxNameList.add(LsxNameJsonArray.optJSONObject(i).get("lsx").toString());
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }
                        lsxNameAdapter = new ArrayAdapter<String>(CheckScanActivity.this, android.R.layout.simple_dropdown_item_1line, LsxNameList);
                        sp_LSX.setAdapter(lsxNameAdapter);
                        sp_LSX.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                //获取列表
                                getMakePersonInfo();
                            }

                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                    }
                    //获取制单人
                    getMakePersonInfo();
                    break;
                //获取组别
                case MSG_FIND_ZDR:
                    if (ZDRJsonArray != null && ZDRJsonArray.length() > 0) {
                        try {
                            if (ZDRJsonArray.getJSONObject(0).has("InputID")) {
                                inputId = ZDRJsonArray.getJSONObject(0).get("InputID").toString();
                            }
                            if (ZDRJsonArray.getJSONObject(0).has("EmpYgh")) {
                                ygh = ZDRJsonArray.getJSONObject(0).get("EmpYgh").toString();
                            }
                            if (ZDRJsonArray.getJSONObject(0).has("EmpName")) {
                                yghXm = ZDRJsonArray.getJSONObject(0).get("EmpName").toString();
                            }
                            if (ZDRJsonArray.getJSONObject(0).has("InputName")) {
                                inputMan = ZDRJsonArray.getJSONObject(0).get("InputName").toString();
                                edMakePerson.setText(inputMan);
                            }

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    } else {
                        inputMan = "";
                        inputId = "";
                        edMakePerson.setText("");
                    }
                    getDate();
                    break;
                //获取日期
                case MSG_FIND_DATE:
                    if (cDateJsonarray != null && cDateJsonarray.length() > 0) {
                        try {
                            if (cDateJsonarray.getJSONObject(0).has("ResultKdrq")) {
                                cDate = cDateJsonarray.getJSONObject(0).getString("ResultKdrq");
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                    getList();
                case MSG_ERROR:
                    Toaster.showLong(CheckScanActivity.this, "连接数据库失败");
                    break;
                default:
                    break;
            }
        }
    };

    @OnClick({R.id.btn_start, R.id.iv_on_package_back, R.id.tv_on_package_back, R.id.tv_sure, R.id.tv_checkout_box_operation, R.id.tv_checkout_question_number, R.id.tv_checkout_exception, R.id.tv_check_sure, R.id.tv_ready_commit, R.id.tv_refresh, R.id.bt_sure_barcode})
    public void onViewClicked(View view) {
        String bmName = "";
        String cjName = "";
        String lsxName = "";
        if (deptNameList != null && deptNameList.size() > 0) {
            bmName = spDept.getSelectedItem().toString();
        }
        if (cJnameList != null && cJnameList.size() > 0) {
            cjName = spFactory.getSelectedItem().toString();
        }
        if (LsxNameList != null && LsxNameList.size() > 0) {
            lsxName = sp_LSX.getSelectedItem().toString();
        }
        switch (view.getId()) {

            case R.id.iv_on_package_back:
            case R.id.tv_on_package_back:
                finish();
                break;
            case R.id.tv_sure:
                break;
            case R.id.tv_refresh:
                getList();
                break;
            case R.id.bt_sure_barcode:
                String nowCode = editBarcode.getText().toString();
                if (nowCode.length() > 12 || nowCode.length() == 12) {
                    nowCode = nowCode.substring(nowCode.length() - 12);
                    editBarcode.setText(nowCode);
                    scanCode();
                }
                break;
            //开始扫描
            case R.id.btn_start:
                /**
                 * {
                 *   "bbm": "制衣二部",
                 *   "bmName": "制衣二部(1)",
                 *   "cjName": "裁剪一工场",
                 *   "inputId": "C2101105A",
                 *   "inputMan": "裁一检验5",
                 *   "kdrq": "2021-12-02 00:00:00",
                 *   "lsx": "1-5",
                 *   "token": "7e0daaaed1a1543727122788a4e5398e7c23e88b075a32e3922a6d96b5642db9",
                 *   "txm": "267000980263",
                 *   "ygh": "何树珍",
                 *   "yghXm": "21027477"
                 * }
                 */
                Intent intent4 = new Intent(CheckScanActivity.this, StartScanActivity.class);

                intent4.putExtra("cjName", cjName);
                intent4.putExtra("bigDept", bidDept);
                intent4.putExtra("bmName", bmName);
                intent4.putExtra("lsx", lsxName);
                intent4.putExtra("inputMan", inputMan);
                intent4.putExtra("inputId", inputId);
                intent4.putExtra("kdrq", tvDate.getText().toString());
                intent4.putExtra("token", Constans.token);
                String nowCode1 = editBarcode.getText().toString();
                if (nowCode1.length() > 12 || nowCode1.length() == 12) {
                    nowCode1 = nowCode1.substring(nowCode1.length() - 12);
                } else {
                    nowCode1 = "";
                }
                intent4.putExtra("txm", nowCode1);
                intent4.putExtra("ygh", ygh);
                intent4.putExtra("yghXm", yghXm);
                startActivity(intent4);
                break;
            //备次提交
            case R.id.tv_ready_commit:
//                Intent intent = new Intent(new Intent(CheckScanActivity.this, ReadyCommitActivity.class));
                String uri="zymis://host_zymis:8123/jysmbctj?bbm="+bidDept+"&bmName="+bmName+"&cjName="+cjName+"&inputMan="+inputMan+"&inputId="+inputId+"";
                /**
                 * 参数:bbm,bmName,cjName,inputMan,inputId
                 * 注释:大部门，部门，车间，制单人，制单人id
                 * 示例:zymis://host_zymis:8123/jysmbctj?bbm=制衣一部&bmName=制衣一部(1)&cjName=裁剪一工场&inputMan=管理员&inputId=002001
                 */
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                startActivity(intent);
//                intent.putExtra("cjName", cjName);
//                intent.putExtra("bigDept", bidDept);
//                intent.putExtra("bmName", bmName);
//                intent.putExtra("lsx", lsxName);
//                intent.putExtra("inputMan", inputMan);
//                intent.putExtra("inputId", inputId);
//                startActivity(intent);
                break;
            //检验确认
            case R.id.tv_check_sure:
                Intent intent3 = new Intent(new Intent(CheckScanActivity.this, MakeSureCheckActivity.class));
                intent3.putExtra("cjName", cjName);
                intent3.putExtra("bigDept", bidDept);
                intent3.putExtra("bmName", bmName);
                intent3.putExtra("lsx", lsxName);
                intent3.putExtra("inputMan", inputMan);
                intent3.putExtra("inputId", inputId);
                startActivity(intent3);
                break;
            //裁剪验片尺寸
            case R.id.tv_checkout_box_operation:
                Intent intent1 = new Intent(new Intent(CheckScanActivity.this, TaiorCheckSizeActivity.class));
                intent1.putExtra("cjName", cjName);
                intent1.putExtra("bigDept", bidDept);
                intent1.putExtra("bmName", bmName);
                intent1.putExtra("lsx", lsxName);
                intent1.putExtra("inputMan", inputMan);
                intent1.putExtra("inputId", inputId);
                startActivity(intent1);
                break;
            //裁剪验片疵点
            case R.id.tv_checkout_question_number:
                Intent intent2 = new Intent(CheckScanActivity.this, TaiorCheckQuestionActivity.class);
                intent2.putExtra("cjName", spFactory.getSelectedItem().toString());
                intent2.putExtra("bigDept", bidDept);
                intent2.putExtra("bmName", spDept.getSelectedItem().toString());
                intent2.putExtra("lsx", sp_LSX.getSelectedItem().toString());
                intent2.putExtra("inputMan", inputMan);
                intent2.putExtra("inputId", inputId);
                startActivity(intent2);
                break;
            //质量检验
            case R.id.tv_checkout_exception:
               // startActivity(new Intent(this, QuantityCheck2Activity.class));
                Intent intentz = new Intent(Intent.ACTION_VIEW, Uri.parse("zymis://host_zymis:8123/zljy"));
                startActivity(intentz);
                break;
        }
    }
}
